package com.neusoft.neuiotms.dcom.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.auth.common.bean.UserBean;
import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.neuiotms.dcom.dto.KnowledgeCommentDTO;
import com.neusoft.neuiotms.dcom.service.KnowledgeCommentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "知识库评论")
@RequestMapping(value = "/api/w/knowledge/comment")
@RestController
public class KnowledgeCommentController {

    @Autowired
    private KnowledgeCommentService knowledgeCommentService;

    @ApiOperation("新增评论")
    @PostMapping("/{knowledgeId}")
    public ResultDTO<KnowledgeCommentDTO> create(@RequestBody final KnowledgeCommentDTO dto,
            @PathVariable final Long knowledgeId,
            final UserBean user) {
        return ResultDTO.success(this.knowledgeCommentService.create(dto, user, knowledgeId));
    }

    @ApiOperation("更新评论")
    @PutMapping("/{id}")
    public ResultDTO<KnowledgeCommentDTO> update(@PathVariable final Long id,
            @RequestBody final KnowledgeCommentDTO dto) {
        return ResultDTO.success(this.knowledgeCommentService.update(id, dto));
    }

}
